package com.walle.ak47.commons.aviator;

import java.util.Map;

import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorDouble;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.walle.ak47.commons.utils.DoubleUtils;

public class AmountScale extends AbstractFunction 
{
	@Override
	public AviatorObject call(Map<String, Object> env, AviatorObject arg ) {
		if ( arg == null ) return null ;
		double d = FunctionUtils.getNumberValue(arg, env).doubleValue() ;
		return new AviatorDouble( DoubleUtils.scale(d) );
	}

	@Override
	public String getName() {
		return "amountScale";
	}
}
